package com.budayi.controller;

import com.budayi.common.constants.BasicConstants;
import com.budayi.common.service.SystemFeignClientService;
import com.budayi.entity.SysUser;
import com.budayi.service.SysUserService;
import com.budayi.vo.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author LIBOFEI
 * @ClassName TestController
 * @description
 * @date 2021/4/19 15:08
 * @Version 1.0
 **/
@RestController
public class TestController {

    @Autowired
    private BasicConstants basicConstants;
    @Autowired
    private SysUserService sysUserService;
    @Autowired
    private SystemFeignClientService systemFeignClientService;


    @RequestMapping("/test")
    public Object test(){
      return basicConstants.getFileUrl() + ";" + basicConstants.getMqSpace() + ";";
    }

    //测试封装公共方法
    @RequestMapping("/test/1")
    public Object test1(){
        return sysUserService.queryObjectByPrimaryKey(7L);
    }

    //测试
    @RequestMapping(value = "/test/2",method = RequestMethod.POST)
    public Object test2(PageInfo pageInfo, SysUser user){
        Map<String,Object> map = new HashMap<>();
        List<SysUser> sysUsers =  sysUserService.queryPageInfoObjectListByCondition(pageInfo,user);

        map.put("sysUserList",sysUsers);
        map.put("pageInfo",pageInfo);
        return map;
    }

    //测试feign调用
    @RequestMapping("/test/3")
    public Object test3(String username){
        return systemFeignClientService.testSystemFeignClientService(username);
    }
}
